﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectTeacher.aspx.cs" Inherits="Educational_Teacher_SelectTeacher" %>
<script type="text/javascript">
window.addEvent('domready',function(){
    window.selectedTeacher=function(r){
        if($defined(window.teacherId)&&$defined(window.teacherName))
        {       
            var selectedData=window.datagridForSelectTeacher.getDataByRow(r);
            window.teacherId.set('value',selectedData.teacherId);
            window.teacherName.set('value',selectedData.teacherName);
	        window.windowId.retrieve('instance').close();
        }
    };
    window.loadDataForSelectTeacher=function(){
        window.datagridForSelectTeacher = new omniGrid('dataListForSelectTeacher', {
            columnModel: [
                {header: '教师姓名',dataIndex: 'teacherName',dataType:'string',width:80,sortable:true},
                {header: '性别',dataIndex: 'teacherSex',dataType:'string',width:50,sortable:true},
                {header: '职称',dataIndex: 'teacherId',dataType:'number',width:100,sortable:true,labelFunction:function(rowdata, r, columnModel){
                    return rowdata.jobTitle.dictionaryValue;
                }},
                {header: '登录Id',dataIndex: 'loginId',dataType:'string',width:100,sortable:true},
                {header: '注册时间',dataIndex: 'regTime',dataType:'string',width:150,sortable:true},
                {header: '状态',dataIndex: 'teacherId',dataType:'number',width:70,labelFunction:function(rowdata, r, columnModel){
                    if(rowdata.status==1)
                        return '<span style="color:#0000FF">离职</span>';
                    if(rowdata.status==2)
                        return '<span style="color:#FF0000">锁定</span>';
                    if(rowdata.status==0)
                        return '<span style="color:#0000FF">退休</span>';
                    if(rowdata.status==9)
                        return '正常';
                }},
                {header: '操作',dataIndex: 'teacherId',dataType:'number',width:70,labelFunction:function(rowdata, r, columnModel){
                        return '<a href="#" onclick="window.selectedTeacher('+r.toString()+')">选择</a>';
                }}
            ],
            buttons : [
            ],
            url:'../Ajax/TeacherManage.aspx?Action=searchForSelectTeacher',
            urlMethod:'post',
            urlPostForm:'searchFormForSelectTeacher',
            perPageOptions: [20,50,100,200,500,1000],
            perPage:20,
            height:$('dataListForSelectTeacher').getParent().getParent().getStyle('height').toInt(),
            serverSort:false,
            multipleSelection:false,
            sortHeader:true,
            pagination:true
        });
    };

    window.binddingEventForSelectTeacher=function(){
        $('searchFormForSelectTeacher').getElement('.button').addEvent('click',function(){
            window.datagridForSelectTeacher.options.page=1;
            window.datagridForSelectTeacher.loadData();
        });
    };
    
    window.initializeForSelectTeacher=function(){
        window.windowId=$('<%=Request.QueryString["windowId"] %>');
        window.teacherId=$('<%=Request.QueryString["teacherId"] %>');
        window.teacherName=$('<%=Request.QueryString["teacherName"] %>');
        window.loadDataForSelectTeacher();
        window.binddingEventForSelectTeacher();
    };
    
    window.initForSelectTeacher=function(){
        window.initializeForSelectTeacher();
    };
    
    window.initForSelectTeacher();
});
</script>
<div id="dataListForSelectTeacher"></div>
<div id="formContainerForSelectTeacher" style="display:none;">
<!--搜索条件表单-->
<form id="searchFormForSelectTeacher">
    <span class="span">教师姓名</span>
    <input class="input" style="width:70px;" type="text" name="teacherName" />
    <span class="span">登录ID</span>
    <input class="input" style="width:70px;" type="text" name="loginId" />
    <input class="button" type="button" value="查询" />
</form>
</div>